home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / ifp1s157.zip / PRINTHLP.PAS < prev   
Pascal/Delphi Source File  |  1993-06-26  |  3KB  |  133 lines

  1. program printhlp;
  2.  
  3. uses
  4.   Dos, ifpglobl;
  5.  
  6. const
  7.   minpage = 0;
  8.   maxpage = pgmax;
  9.   infodate = '6/25/93';
  10.   dashes: string[79] = '----------------------------------------' +
  11.                        '---------------------------------------';
  12.  
  13. type
  14.   tabletype = array[0..63] of longint;
  15.  
  16. var
  17.   filename, s: string;
  18.   infile, outfile: text;
  19.   maxlines: byte;
  20.   printpage, x: word;
  21.   thetable: tabletype;
  22.   tablefile: file of tabletype;
  23.  
  24. procedure textseek(var thefile: text; position: longint);
  25.   var
  26.     segment, offset: word;
  27.     regs: registers;
  28.  
  29.   begin
  30.   segment:=Seg(thefile);
  31.   offset:=Ofs(thefile);
  32.   MemW[segment:offset + 8]:=0;
  33.   MemW[segment:offset + 10]:=0;
  34.   with regs do
  35.     begin
  36.     BX:=MemW[segment:offset];
  37.     CX:=position shr 16;
  38.     DX:=position and $0000FFFF;
  39.     AH:=$42;
  40.     AL:=0;
  41.     MsDos(regs);
  42.     end;
  43.   end;
  44.  
  45. procedure printapage(page: word);
  46.   var
  47.     endit: boolean;
  48.     linecount: byte;
  49.     s: string;
  50.  
  51.   begin
  52.   Str(page, s);
  53.   if page < 10 then
  54.     s:='0' + s;
  55.   Assign(infile, 'INFOPLUS.HLP');
  56.   Reset(infile);
  57.   textseek(infile, thetable[page]);
  58.   Writeln(outfile, dashes);
  59.   Writeln(outfile, 'Infoplus ', vernum, '   Page ', page,
  60.                    ' - ', pgnames[page]);
  61.   Writeln(outfile, dashes);
  62.   Writeln(outfile);
  63.   linecount:=4;
  64.   endit:=false;
  65.   repeat
  66.     Readln(infile, s);
  67.     if s = '$END' then
  68.       endit:=true
  69.     else
  70.       begin
  71.       Writeln(outfile, s);
  72.       Inc(linecount);
  73.       if (linecount <> 255) and (linecount = maxlines) then
  74.         begin
  75.         Writeln(outfile, #12);
  76.         linecount:=1
  77.         end;
  78.       end;
  79.     until endit;
  80.   Close(infile);
  81.   Write(outfile, #12);
  82.   end;
  83.  
  84. begin
  85. Writeln('PRINTHLP ver 1.57 by Andrew Rossmann. For use with Infoplus 1.57');
  86. Writeln('PRINTHLP prints out the .HLP pages to your printer. Each page');
  87. Writeln('will have a header describing which Infoplus page it belongs to.');
  88. Writeln;
  89. repeat
  90.   Write('Which page to print? 0 - ', maxpage, ', 99 for all.=> ');
  91.   Readln(printpage);
  92. until (printpage in [0..maxpage]) or (printpage = 99);
  93. Write('Which device to you wish to print to? <ENTER> for PRN.=> ');
  94. Readln(filename);
  95. if filename = '' then
  96.   filename:='PRN';
  97. Assign(outfile, filename);
  98. {$I-} ReWrite(outfile); {$I+}
  99. if IOResult <> 0 then
  100.   begin
  101.   Writeln(^G'Unable to open ', FExpand(filename), ' for output!!');
  102.   Exit;
  103.   end;
  104. Write('How many lines per page? <ENTER> for 60, 255 for continuous.=> ');
  105. Readln(s);
  106. maxlines:=0;
  107. Val(s, maxlines, x);
  108. if maxlines = 0 then
  109.   maxlines:=60;
  110. Assign(tablefile, 'INFOPLUS.HLP');
  111. {$I-} Reset(tablefile); {$I+}
  112. if IOResult <> 0 then
  113.   begin
  114.   Writeln(^G'Unable to open INFOPLUS.HLP!');
  115.   Halt
  116.   end;
  117. Read(tablefile, thetable);
  118. Close(tablefile);
  119. if thetable[63] <> helpversion then
  120.   begin
  121.   Writeln(^G'Incorrect version of INFOPLUS.HLP!');
  122.   Writeln('Found version ', (thetable[63] / 100.0):0:2);
  123.   Halt
  124.   end;
  125. if printpage = 99 then
  126.   for x:=0 to maxpage do
  127.     printapage(x)
  128. else
  129.   printapage(printpage);
  130. Close(outfile);
  131. Writeln('Information printing completed.');
  132. end.
  133.